package controller.eventListener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JRadioButton;

import model.spring.AddressList;

import controller.strategy.HighBudget;
import controller.strategy.LowBudget;
import controller.strategy.Strategy;

public class ActionListener_SendMessageButton implements ActionListener {

	JRadioButton low,high;
	AddressList addressList;
	private Strategy strategy = null;
	
	public ActionListener_SendMessageButton(JRadioButton low, JRadioButton high, AddressList addressList) {
		this.low =low;
		this.high = high;
		this.addressList = addressList;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		if(low.isSelected()) {
			setStrategy(new LowBudget());
			work(addressList);	
		} else if(high.isSelected()) {
			setStrategy(new HighBudget());
			work(addressList);
		}
		else 
			System.out.println("Jetzt passiert gar nix");	
	}
	
	public void setStrategy(final Strategy STRATEGY) {
        strategy = STRATEGY;
	}
	
	public void work(AddressList addressList) {
        if (strategy != null)
                strategy.doWork(addressList);
	}	

}
